home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
raytrace
/
rayshade
/
graphtal.lzh
/
Graphtal.Amiga
/
yyerror.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-17
|
1KB
|
62 lines
/*
* yyerror.C - error function for parser.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#include <stdlib.h>
#include <stream.h>
#include "yyerror.h"
rcString currentFilename;
int yyerror(const char* msg)
{
extern int yynerrs;
extern int lineno; // current line number
extern char* yytext;
char colon = 0;
cerr << "[Error " << yynerrs << "] ";
if (!currentFilename.empty())
cerr << "File \'" << currentFilename << "\', ";
if (lineno > 0) {
cerr << "line " << 1+lineno-(*yytext == '\n' || *yytext);
colon = 1;
}
if (*yytext)
{
int i;
for (i = 0; i < 20; ++i)
if (!yytext[i] || yytext[i] == '\n')
break;
if (i > 0)
{
if (colon) cerr << " ";
cerr << "near \"" << form("%.*s\" ", i, yytext);
colon = 1;
}
}
if (colon)
cerr << ": ";
cerr << msg << "!\n";
cerr.flush();
exit(1);
return 1;
}